package com.sinodata.bsm.center.bean;

import java.util.List;

import com.sinodata.bsm.center.cache.*;
import com.sinodata.bsm.center.util.spring.SpringContextHolder;
import com.sinodata.bsm.common.vo.*;

public class CollectTaskBean {
    private static CollectTaskCache collectTaskCache = SpringContextHolder.getBean(CollectTaskCache.class);

    private static CollectParamCache collectParamCache = SpringContextHolder.getBean(CollectParamCache.class);
    private static CollectFieldCache collectFieldCache = SpringContextHolder.getBean(CollectFieldCache.class);
    private static CollectScheduleCache collectScheduleCache = SpringContextHolder.getBean(CollectScheduleCache.class);

    private static CollectorCache collectorCache = SpringContextHolder.getBean(CollectorCache.class);

    private CollectTaskBean() {
    }

    private CollectTaskBean(CollectTask _collectTask) {
        this.collectTask = _collectTask;
    }

    private CollectTask collectTask;

    public static CollectTaskBean get(Long taskId) {

        return new CollectTaskBean(collectTaskCache.get(taskId.longValue()));
    }

    public CollectTask collectTask() {
        return collectTask;
    }

    public List<CollectParam> getCollectParam() {
        return collectParamCache.get(collectTask.getId());
    }

    public List<CollectField> getCollectField() {
        return collectFieldCache.get(collectTask.getId());
    }

    public List<CollectSchedule> getCollectSchedule() {
        return collectScheduleCache.get(collectTask.getId());
    }

    public Collector getCollector() {
        return collectorCache.get(collectTask.getCollectorId());
    }

    public boolean isResTypeCollectTask() {
        return collectTask.getResId() == null ? true : false;
    }

}
